/**
 * @author LKQ
 * @date 2022/1/13 9:53
 * @description
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int dominantIndex(int[] nums) {
        int n = nums.length, max = 0, location = 0;
        if (n == 1) {
            return 0;
        }
        for (int i = 0; i < n; i++) {
            if (nums[i] > max) {
                max = nums[i];
                location = i;
            }
        }
        int count = 0;
        for (int num : nums) {
            if (max != num && max >= num * 2) {
                count++;
            }
        }
        if (count == n-1) {
            return location;
        }
        return -1;
    }
}
